<template>
  <div>
    <a-input v-model:value="name" placeholder="请输入姓名" @pressEnter="changeName" />
    <a-input v-model:value="age" placeholder="请输入姓名" @pressEnter="change" />
    <a-button type="link">{{ btn }}</a-button>
  </div>
</template>
<script setup>
// import { defineProps, defineExpose } from 'vue'
const handle = defineEmits(['handleChangeAge', 'changeName'])

const props = defineProps(['age'])
const age = ref(props.age)
const name = ref('')
const btn = ref('按钮')

const change = () => {
  handle('handleChangeAge', age.value)
}
const changeName = () => {
  handle('changeName', name.value)
}
const changeBtnValue = () => {
  btn.value = '按钮' + Math.random(2) * 100
}

// 主动暴露childMethod方法
defineExpose({ changeBtnValue })
</script>
<style></style>
